<template>
<div>
  <div class="common-layout">
    <el-container>
      <el-aside width="200px" direction="vertical"><div>
        <div style="display: flex; width: 200px; justify-content: flex-end; align-items: flex-end">
        <el-avatar :size="75" :src="this.inform.img"></el-avatar></div>
      </div></el-aside>
      <el-main>
        <div >
        <el-descriptions :title="this.info.title" class="margin-top">
          <template #extra>
            <el-button type="primary" @click="this.$router.back()">返回</el-button>
          </template>
          <el-descriptions-item label="作者：">{{this.info.author}}</el-descriptions-item>
          <el-descriptions-item label="论文类别：">{{this.info.type}}</el-descriptions-item>
          <el-descriptions-item label="分数：">{{this.info.score}}</el-descriptions-item>
          <el-descriptions-item label="审核状态：">
            <el-tag
                :type="this.info.status === '审核中' ? 'primary' : 'success'"
                disable-transitions>{{this.info.status}}</el-tag>
          </el-descriptions-item>
          <el-descriptions-item label="上传时间："
                                >{{this.info.uploadTime}}
            </el-descriptions-item
          >
          <el-descriptions-item label="下载："><a :href="this.info.download">点击下载</a></el-descriptions-item>
          <el-descriptions-item label="摘要：">{{this.info.paperAbstract}}</el-descriptions-item>
        </el-descriptions>
        </div>
      </el-main>
    </el-container>
  </div>
</div>
</template>

<script >

import  {useRouter}  from "vue-router";
import axios from "axios";
import {ElMessage} from "element-plus";
import {defineComponent, reactive, ref} from 'vue';
const visible = ref(false);

export default {
  data(){
    return {
      inform:{
        name:'',
        personalProfile:'',
        id:'',
        img:'',
        telephone:'123',
        token:''
      },
      info:{
        title: '',
        author:'',
        paperAbstract:'',
        score: '',
        type:'',
        uploadTime: '',
        status: '',
        download:''
      },
    }
  },
  created(){
    //页面加载时就从本地通过localstorage获取存储的token值
    this.token =  localStorage.getItem('ID');
    this.id = this.token;
  },
  mounted() {
    this.$http({
      method: 'get',
      url: '/user/info',
      headers: {
        //把token放到请求头才能请求，这里的'Bearer '表示是后台希望更加的安全，依据后台给的信息看到底是加还是不加
        'session':  this.token,
      }
    })
        .then(res=>{                    //请求成功后执行函数
          if(res.data.code === 0){
            //请求成功之后给用户名赋值
            this.inform.name=res.data.data.nickname;
            this.inform.personalProfile = res.data.data.personalProfile;
            this.inform.id=res.data.data.id;
            this.inform.telephone = res.data.data.telephone;
            this.inform.img = ref(res.data.data.portrait);
            console.log("登录成功")
          }else{
            console.log("登录失败")
          }
        })
        .catch(err=>{                   //请求错误后执行函
          console.log("请求错误")
        });

    console.log(this.$route)
    let num =  this.$route.query.paperId;
    console.log(num);
    axios.get(`paper?paperId=${num}`,
        {
          headers: {
            'Content-Type': 'application/json',
            'session': localStorage.getItem('ID'),
          }
        }).then(res => {
      if (res.data.code === 0) {
        this.info.type = res.data.data.type;
        this.info.paperAbstract = res.data.data.paperAbstract;
        this.info.score = res.data.data.score;
        this.info.title = res.data.data.title;
        this.info.uploadTime = res.data.data.uploadTime;
        this.info.author = res.data.data.authorOneName;
        this.info.download = res.data.data.filePath;
        let alter = res.data.data.status;
        if(alter == 1) this.info.status = '已通过'
        else this.info.status = '审核中'
        console.log(res.data.data)
      } else {
        ElMessage('删除失败');
      }
    });

  },
  methods:{}
}




</script>
<style scoped>

</style>